package sphere.view;
import java.awt.*;
import java.awt.event.*;

import sphere.controller.SphereController;

public class SphereWindow extends Frame{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	Label LabelRadius, LabelVolume, LabelSurfaceArea;
	TextField TextFieldRadius,TextFieldVolume,TextSurfaceArea ;
	Panel monPanel;
	
	public SphereWindow ( String title,SphereController mysphereController ) {
		super ( title ) ;
		this.addWindowListener(new MonWindowListener());
		mysphereController.setView(this);
		setLayout (new FlowLayout ( FlowLayout . LEFT ) ) ;	
		monPanel = new Panel ( ) ;
		monPanel.setLayout (new GridLayout ( 3,2 ) ) ;
		LabelRadius =new Label ( " radius : " );
		LabelVolume =new Label ( " volume : " );
		LabelSurfaceArea =new Label ( " surface area : " );
		TextFieldRadius =new TextField ( 10 ) ;
		TextFieldRadius.setBackground(Color.yellow);
		TextFieldVolume =new TextField ( 10 ) ;
		TextFieldVolume.setEnabled(false);
		TextSurfaceArea =new TextField ( 10 ) ;
		TextSurfaceArea.setEnabled(false);
		
		this.add(monPanel);
		monPanel.add(LabelRadius);	
		monPanel.add ( TextFieldRadius ) ;
		monPanel.add(LabelVolume);	
		monPanel.add ( TextFieldVolume ) ;
		monPanel.add(LabelSurfaceArea);	
		monPanel.add ( TextSurfaceArea ) ;
		
		this.pack();
		this.setVisible(true);
		this.setResizable(false);

		TextFieldRadius.addTextListener (mysphereController) ;

	}

	public void SetSurface(double surface)
	{
		this.TextSurfaceArea.setText(String.valueOf(surface));
	}

	public void SetVolume(double volume)
	{
		this.TextFieldVolume.setText(String.valueOf(volume));
	}

}
